home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp2.arc / PIBDUMBT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-10-04  |  6.3 KB  |  137 lines

  1. (*----------------------------------------------------------------------*)
  2. (*          PIBDUMBT.PAS --- Emulate Dumb Terminal for PIBTERM          *)
  3. (*----------------------------------------------------------------------*)
  4. (*                                                                      *)
  5. (*  Author:  Philip R. Burns                                            *)
  6. (*  Version: 1.0   (January, 1985)                                      *)
  7. (*           2.0   (June, 1985)                                         *)
  8. (*  Systems: For MS-DOS on IBM PCs and close compatibles only.          *)
  9. (*           Note:  I have checked these on Zenith 151s under           *)
  10. (*                  MSDOS 2.1 and IBM PCs under PCDOS 2.0.              *)
  11. (*                                                                      *)
  12. (*  Needs:   The Menu routines from PIBMENUS.PAS, communications        *)
  13. (*           routines from PIBASYNC.PAS, and various global variables   *)
  14. (*           from PIBTERM.PAS.                                          *)
  15. (*                                                                      *)
  16. (*  History: Original with me.                                          *)
  17. (*                                                                      *)
  18. (*           Suggestions for improvements or corrections are welcome.   *)
  19. (*           Please leave messages on Gene Plantz's BBS (312) 882 4145  *)
  20. (*           or Ron Fox's BBS (312) 940 6496.                           *)
  21. (*                                                                      *)
  22. (*           If you use this code in your own programs, please be nice  *)
  23. (*           and give proper credit.                                    *)
  24. (*                                                                      *)
  25. (*----------------------------------------------------------------------*)
  26.  
  27. OVERLAY PROCEDURE Emulate_Dumb_Terminal;
  28.  
  29. (*----------------------------------------------------------------------*)
  30. (*                                                                      *)
  31. (*     Procedure:  Emulate_Dumb_Terminal                                *)
  32. (*                                                                      *)
  33. (*     Purpose:    Controls dumb terminal emulation                     *)
  34. (*                                                                      *)
  35. (*     Calling Sequence:                                                *)
  36. (*                                                                      *)
  37. (*        Emulate_Dumb_Terminal;                                        *)
  38. (*                                                                      *)
  39. (*      Calls:   Async_Send                                             *)
  40. (*               Async_Receive                                          *)
  41. (*               KeyPressed                                             *)
  42. (*               Process_Command                                        *)
  43. (*               Display_Character                                      *)
  44. (*               ClrScr                                                 *)
  45. (*               Async_Buffer_Full                                      *)
  46. (*                                                                      *)
  47. (*      Remarks:                                                        *)
  48. (*                                                                      *)
  49. (*         You can replace this with something smarter --- i.e.,        *)
  50. (*         a VT100 emulator, or whatever you like.                      *)
  51. (*                                                                      *)
  52. (*----------------------------------------------------------------------*)
  53.  
  54. VAR
  55.    Done: BOOLEAN           (* TRUE to exit terminal emulation mode *);
  56.    Ch  : CHAR              (* Character read/written               *);
  57.  
  58. BEGIN (* Emulate_Dumb_Terminal *)
  59.  
  60.    Save_Screen( Saved_Screen );
  61.    Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
  62.                     Menu_Text_Color, '' );
  63.  
  64.    WRITELN('Beginning Dumb Terminal Emulation');
  65.    DELAY( One_Second_Delay );
  66.  
  67.    Restore_Screen( Saved_Screen );
  68.    Reset_Global_Colors;
  69.  
  70.    Auto_Wrap_Mode := TRUE;
  71.    Done           := FALSE;
  72.                                    (* Loop over input until done *)
  73.    WHILE ( NOT Done ) DO
  74.       BEGIN
  75.                                    (* Check for character typed at keyboard *)
  76.          IF KeyPressed THEN
  77.             BEGIN
  78.  
  79.                READ( Kbd , Ch );
  80.  
  81.                CASE ORD( Ch ) OF
  82.  
  83.                   ESC:  IF KeyPressed THEN
  84.                            BEGIN
  85.                               Process_Command( Ch, FALSE, PibTerm_Command );
  86.                               IF PibTerm_Command <> Null_Command THEN
  87.                                  Execute_Command( PibTerm_Command, Done, FALSE );
  88.                            END
  89.                         ELSE
  90.                            BEGIN
  91.                               IF Local_Echo THEN WRITE( Ch );
  92.                               Async_Send( Ch );
  93.                            END;
  94.  
  95.                   BS:   BEGIN
  96.                            Ch := BS_Char;
  97.                            IF Local_Echo THEN WRITE( Ch );
  98.                            Async_Send( Ch );
  99.                         END;
  100.  
  101.                   DEL:  BEGIN
  102.                            Ch := Ctrl_BS_Char;
  103.                            IF Local_Echo THEN WRITE( Ch );
  104.                            Async_Send( Ch );
  105.                         END;
  106.  
  107.                   ELSE
  108.                         BEGIN
  109.                            IF Local_Echo THEN WRITE( Ch );
  110.                            Async_Send( Ch );
  111.                         END;
  112.  
  113.                END (* CASE ORD( Ch ) *);
  114.  
  115.             END;
  116.  
  117.          IF ( Script_File_Mode AND ( NOT ( Done OR Really_Wait_String ) ) ) THEN
  118.             BEGIN
  119.                Get_Script_Command( PibTerm_Command );
  120.                Execute_Command   ( PibTerm_Command , Done , TRUE );
  121.             END;
  122.  
  123.          IF Async_Receive( Ch ) THEN
  124.             BEGIN
  125.                                    (* Check if XOFF needs to be sent *)
  126.                Async_Buffer_Full;
  127.  
  128.                                    (* Display the character received *)
  129.  
  130.                Display_Character( TrTab[Ch] );
  131.  
  132.             END;
  133.  
  134.       END;
  135.  
  136. END   (* Emulate_Dumb_Terminal *);
  137.